﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using CE.Mail;
using CE.Database;
using CE.AreaCountry;
using CE.Global;
using CE.TravelInsurance;
using CE.User;
using CE.Security;
//using CE.Payment;

public partial class travel_forms_liberty_form : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void csvCreditCardValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        bool _status = true;

        string _first = "";

        if (txtCardNo1.Text.Length > 0)
        {
            _first = txtCardNo1.Text.Trim().Substring(0, 1);
        }
        if (rdoVisa.Checked)
        {
            if (_first != "4")
            {
                _status = false;
            }
        }
        else if (rdoMasterCard.Checked)
        {
            if (_first != "5")
            {
                _status = false;
            }
        }
        if (_status == true)
        {
            txtCreditCardValid.Text = "";
            txtCreditCardValid.Text = txtCardNo1.Text.Trim() + "" + txtCardNo2.Text.Trim() + "" + txtCardNo3.Text.Trim() + "" + txtCardNo4.Text.Trim();
            string _cardNumer = txtCreditCardValid.Text;
            MySecurity _mysecurity = new MySecurity();
            if (_mysecurity.IsCreditCardValid(_cardNumer))
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = false;
        }
    }

    protected void csvCCExpiredValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        txtCCExpiredValid.Text = "";
        txtCCExpiredValid.Text = "valid";
        Int32 _Year = Convert.ToInt32(ddlCardExpiryYear.Text);
        Int32 _Month = Convert.ToInt32(ddlCardExpiryMonth.Text);

        MySecurity _mysecurity = new MySecurity();
        if (_mysecurity.IsCreditCardExpiredDateValid(_Year, _Month))
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }
    }
}
